<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>排班管理</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="./css/font.css">
        <link rel="stylesheet" href="./css/xadmin.css">
        <script src="./lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="./js/xadmin.js"></script>
        <script src="./js/jquery.min.js"></script>
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
          </span>
          <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">

                            <form class="layui-form layui-col-space5" lay-filter="example">

                                <div class="layui-inline layui-show-xs-block">
                                    <input type="text" name="doctorName" id="doctorName" placeholder="请输医生名" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="button" class="layui-btn layui-icon"  lay-submit="" lay-filter="sreach"  value=&#xe615;></input>
                                </div>
                            </form>
                        </div>

                        <div class="layui-card-body ">
                            <table class="layui-table layui-form layui-hide" id="test" lay-filter="test">

                            </table>
                        </div>

                    </div>
                </div>
            </div>
        </div> 
    </body>

    <script type="text/html" id="action">


            <a title="修改" lay-event="edit" href="javascript:;">
                <i class="layui-icon">&#xe63c;</i>
            </a>


    </script>

    <script>
        layui.use(['form','table'], function(){
            var table = layui.table;
            var form = layui.form;

            form.on('submit(sreach)', function(data){
                var doctorName = $("#doctorName").val();


                table.render({
                    elem: '#test'
                    ,url: '/hospital/api/back/schedule/limit' //数据接口
                    ,page: true //开启分页
                    ,limit:20
                    ,headers: {
                        'token':token
                    }
                    ,where: {"doctorName":doctorName}
                    ,done:function () {//渲染完成后的回调

                    },parseData:function(res){
                        return {
                            "code": res.code, //解析接口状态
                            "msg": res.msg, //解析提示文本
                            "count": res.data.total, //解析数据长度
                            "data": res.data.list //解析数据列表
                        };

                    },response:{
                        statusCode:0
                    }
                    ,cols: [[ //表头
                        //,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计'}
                        {field: 'scheduleId', title: 'ID', hide:true}
                        ,{field: 'doctorName', title: '医生',}
                        ,{field: 'amOne', title: '星期一上午',edit:'text'}
                        ,{field: 'pmOne', title: '星期一下午', edit:'text'}
                        ,{field: 'amTwo', title: '星期二上午', edit:'text'}
                        ,{field: 'pmTwo', title: '星期二下午', edit:'text'}
                        ,{field: 'amThree', title: '星期三上午',edit:'text'}
                        ,{field: 'pmThree', title: '星期三下午',edit:'text'}
                        ,{field: 'amFour', title: '星期四上午',edit:'text'}
                        ,{field: 'pmFour', title: '星期四下午', edit:'text'}
                        ,{field: 'amFive', title: '星期五上午', edit:'text'}
                        ,{field: 'pmFive', title: '星期五下午',edit:'text'}
                        ,{field: 'amSix', title: '星期六上午',edit:'text'}
                        ,{field: 'pmSix', title: '星期六下午', edit:'text'}
                        ,{field: 'amSeven', title: '星期天上午', edit:'text'}
                        ,{field: 'pmSeven', title: '星期天下午',edit:'text'}
                        ,{fixed:'right',title:'操作',toolbar:'#action'}
                    ]]
                });
            });
        });


    </script>

    <script>
        var token =  localStorage.getItem("token");
        var  head = new Headers();
        head.append('token',token);
        layui.use(['layer', 'form','table'], function(){
            var table = layui.table;
            var form = layui.form;


            table.render({
                elem: '#test'
                ,url: '/hospital/api/back/schedule/limit' //数据接口
                ,page: true //开启分页
                ,limit:20
                ,headers: {
                    'token':token
                }
                ,done:function () {//渲染完成后的回调

                },parseData:function(res){
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.total, //解析数据长度
                        "data": res.data.list //解析数据列表
                    };

                },response:{
                    statusCode:0
                }
                ,cols: [[ //表头
                    //,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计'}
                    {field: 'scheduleId', title: 'ID', hide:true}
                    ,{field: 'doctorName', title: '医生',}
                    ,{field: 'amOne', title: '星期一上午',edit:'text'}
                    ,{field: 'pmOne', title: '星期一下午', edit:'text'}
                    ,{field: 'amTwo', title: '星期二上午', edit:'text'}
                    ,{field: 'pmTwo', title: '星期二下午', edit:'text'}
                    ,{field: 'amThree', title: '星期三上午',edit:'text'}
                    ,{field: 'pmThree', title: '星期三下午',edit:'text'}
                    ,{field: 'amFour', title: '星期四上午',edit:'text'}
                    ,{field: 'pmFour', title: '星期四下午', edit:'text'}
                    ,{field: 'amFive', title: '星期五上午', edit:'text'}
                    ,{field: 'pmFive', title: '星期五下午',edit:'text'}
                    ,{field: 'amSix', title: '星期六上午',edit:'text'}
                    ,{field: 'pmSix', title: '星期六下午', edit:'text'}
                    ,{field: 'amSeven', title: '星期天上午', edit:'text'}
                    ,{field: 'pmSeven', title: '星期天下午',edit:'text'}
                    ,{fixed:'right',title:'操作',toolbar:'#action'}
                ]]
            });



            //监听table中的工具栏
            table.on('tool(test)',function(obj) {
                var data = obj.data;
                console.log(data);
                switch (obj.event) {
                    case 'edit':
                        layer.confirm("确定要修改"+obj.data.doctorName+"的排班信息吗?",function (index) {
                            $.ajax({
                                url:"/hospital/api/back/schedule/modify",
                                type:"post",
                                dataType:"json",
                                headers: {
                                    'token':token
                                },
                                data:{"scheduleId":data.scheduleId,"amFive":data.amFive,"amFour":data.amFour,"amOne":data.amOne,
                                    "amSeven":data.amSeven,"amSix":data.amSix,"amThree":data.amThree,"amTwo":data.amTwo,
                                    "pmFive":data.pmFive,"pmFour":data.pmFour,"pmOne":data.pmOne,"pmSeven":data.pmSeven,
                                    "pmSix":data.pmSix,"pmThree":data.pmThree,"pmTwo":data.pmTwo,},
                                success:function (msg) {
                                    //console.log("删除数据"+msg);
                                    if(msg.code==0){
                                        layer.msg("修改成功！");
                                    }else {
                                        layer.msg("修改失败");
                                    }
                                }
                            });
                        });
                        break;
                }
            });

        });





    </script>


</html>